// server.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <iostream>
using namespace std;

#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/bind.hpp>
using namespace boost::asio;
using namespace boost;

int _tmain(int argc, _TCHAR* argv[])
{
  try
  {
    cout << "server start." << endl;
    io_service ios;
    ip::tcp::acceptor acceptor(ios, ip::tcp::endpoint(ip::tcp::v4(), 6688));
    cout << acceptor.local_endpoint().address() << endl;

    while(true)
    {
      ip::tcp::socket sock(ios);
      acceptor.accept(sock);

      cout << "client:";
      cout << sock.remote_endpoint().address() << endl;

      sock.write_some(buffer("hello asio"));
    }
  }
  catch (...)
  {
  }

	return 0;
}

